package jdbc.lessen02;


import jdbc.lessen02.util.JdbcUtil;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Package lessen02
 * @Author shimmer
 * @Date 2020/7/31 11:29
 * @TODO
 */
public class TestUpdate {
    public static void main(String[] args) {
        Statement st = null;
        Connection conn = null;
        try {
            conn = JdbcUtil.getConnection();
            st = conn.createStatement();

            //UPDATE `user` SET `pwd`='520' WHERE `id`='3';
            String sql = "UPDATE `user` SET `pwd`='520' WHERE `id`='1'";
            int i = st.executeUpdate(sql);
            if (i > 0) {
                System.out.println("更新成功！");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JdbcUtil.release(null, st, conn);
        }
    }
}
